<template lang="pug">
.view.cp-train-lib-standardrule.fix-flex-pos
  //- 查询
  el-form.tlsta-search(:inline="true")
    el-form-item(label="关键字 :")
      el-input(
        v-model="keyword",
        placeholder="关键字",
        style="width: 200px")
    el-form-item(label="标准号 :")
      el-input(
        v-model="standardCode",
        placeholder="标准号",
        style="width: 200px")
    el-form-item(label="产品 :")
      el-select.select-width(v-model="product", placeholder="请选择")
        el-option(label="全部", :value="null")
        el-option(
          v-for="(item, index) in productSelect",
          :key="index",
          :label="item.name",
          :value="item.value")
    el-form-item(label="标准来源 :")
      el-select.select-width(v-model="standardSource", placeholder="请选择")
        el-option(label="全部", :value="null")
        el-option(
          v-for="(item, index) in standardSourceSelect",
          :key="index",
          :label="item.name",
          :value="item.value")
    el-form-item
      el-button(type="primary", @click="search") 搜索
    el-form-item
      el-button(type="primary", @click="showDialog", plain) 智能提醒
  //- 表格
  .tlsta-table
    el-table(
      :data="dataList",
      highlight-current-row,
      v-loading="loadingData",
      size="mini",
      height="100%")
      el-table-column(show-overflow-tooltip, type="index", label="序号")
      el-table-column(show-overflow-tooltip, prop="standardOrg", label="标准组织")
      el-table-column(show-overflow-tooltip, prop="standardCode", label="标准号")
      el-table-column(show-overflow-tooltip, prop="standardName", label="标准名称")
      el-table-column(show-overflow-tooltip, label="发布日期", min-width="90px")
        template(slot-scope="scope")
          span {{ scope.row.publishTime | date-format }}
      el-table-column(show-overflow-tooltip, label="废止日期", min-width="90px")
        template(slot-scope="scope")
          span {{ scope.row.closeTime | date-format }}
  //- 分页
  el-pagination.tlsta-pagination(
    background,
    layout="total, prev, pager, next, jumper",
    prev-text="上一页",
    next-text="下一页",
    @current-change="handleCurrentChange",
    :current-page="pageNum",
    :page-size="pageSize",
    :total="totalNum")
  el-dialog.tlsta-pop(
    title="智能提醒",
    :visible.sync="showModal",
    width="30%")
    el-form.tlsta-pop-form(:model="formData", label-width="120px", label-position="left")
      el-form-item(label="选择关注的内容")
        el-input(v-model="formData.follow", placeholder="法规/标准")
      el-form-item(label="法规关键字")
        el-input(v-model="formData.ruleKeyword")
      el-form-item(label="发布机构")
        el-input(v-model="formData.publisher", placeholder="CFDA/FDA/CE")
      el-form-item(label="标准关键字")
        el-input(v-model="formData.standardKeyword")
      el-form-item(label="标准号")
        el-input(v-model="formData.standardCode")
      el-form-item(label="标准发布单位")
        el-input(v-model="formData.standardPublisher")
      el-form-item(label="设置提醒时间")
        el-date-picker(v-model="formData.remarkTime", type="datetime")
    .dialog-footer(slot="footer")
      el-button(type="primary", plain, @click="showModal = false") 取消
      el-button(type="primary", @click="submit") 保存
</template>

<script>
import { mapGetters } from 'vuex';
import TrainData from '@/data/train';

export default {
  name: 'trastandardrule',
  data() {
    return {
      loadingData: true,
      dataList: [],
      pageNum: 1,
      pageSize: 16,
      totalNum: 0,
      // 搜索条件
      keyword: null,
      standardCode: null,
      product: null,
      standardSource: null,
      // 弹出框
      showModal: false,
      formData: {},
      // 搜索下拉框

      productSelect: [
        { name: 'Regional', value: 0 },
        { name: 'Coordinator', value: 1 },
        { name: 'Directives', value: 2 }
      ],
      standardSourceSelect: [
        { name: '奥兹达', value: 0 },
        { name: '捷通', value: 1 },
        { name: '新浪', value: 2 }
      ]
    };
  },
  computed: {
    ...mapGetters({
      creator: 'employeeId'
    })
  },
  created() {
  },
  mounted() {
    this.loadDataList();
  },
  methods: {
    filterParams() {
      const params = {
        keyword: this.keyword,
        product: this.product,
        standardSource: this.standardSource,
        pageNum: this.pageNum,
        pageSize: this.pageSize
      };
      for (const key in params) {
        if (params[key] === null || params[key] === '') {
          delete params[key];
        }
      }
      return params;
    },
    // 取得表格数据
    loadDataList() {
      this.loadingData = true;
      // const params = this.filterParams();
      setTimeout(() => {
        this.dataList = TrainData.standardruleList;
        this.totalNum = 56;
        this.loadingData = false;
      }, 1000);
    },
    // 搜索
    search() {
      if (this.pageNum !== 1) {
        this.pageNum = 1;
      }
      this.loadDataList();
    },
    // 页码改变
    handleCurrentChange(pageNum) {
      this.pageNum = pageNum;
      this.loadDataList();
    },
    // 显示popup
    showDialog() {
      this.showModal = true;
    },
    // 保存
    submit() {
      this.showModal = false;
    }
  }
};
</script>

<style lang="sass">
@import "../../../styles/utils"
$SEARCHHEIGHT: 56px
$PAGEHEIGHT: 56px
$SELECTWIDTH: 100px
.cp-train-lib-standardrule
  .tlsta-search
    height: $SEARCHHEIGHT
    padding: 12px 0 12px 16px
    overflow-x: auto
    overflow-y: hidden
    .select-width
      width: $SELECTWIDTH
    .date-width
      width: 260px
    .el-form-item
      margin-right: 14px
    .el-form-item__label
      margin-left: 6px
      padding-right: 6px
    .el-date-editor .el-range__close-icon
      width: 20px
    .el-form-item--small .el-form-item__content, .el-form-item--small .el-form-item__label
      height: 32px
  .tlsta-table
    position: absolute
    top: $SEARCHHEIGHT
    bottom: $PAGEHEIGHT
    left: 16px
    right: 16px
    overflow-x: hidden
    overflow-y: auto
    &::before
      display: none
    .icon-act
      font-size: 16px
      font-weight: 500
      cursor: pointer
      margin-left: 3px
      margin-right: 3px
      &:hover
        color: #5D9BFB
  .el-table
    th, td
      text-align: center
  .tlsta-pagination
    position: absolute
    bottom: 12px
    left: 0
    right: 0
    text-align: center
  .tlsta-pop
    &::-webkit-scrollbar
      display: none
    .el-dialog__footer
      text-align: center
      padding-top: 0
      .el-button
        width: 80px
    .el-date-editor
      width: 100%
</style>
